package com.fast.service;

import org.springframework.aop.framework.AopContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;
import java.util.concurrent.TimeUnit;

@Service
public class DemoService {

    @Autowired
    Map<String, IStrategy> processStrategy;


    public void testTrace() throws InterruptedException {
        DemoService self = (DemoService) AopContext.currentProxy();
        self.ddd();
        TimeUnit.SECONDS.sleep(3);
    }

    public void ddd() {
        IStrategy sayStrategy = processStrategy.get("sayStrategy");

        IStrategy listenStrategy = processStrategy.get("listenStrategy");

        sayStrategy.doWork("bbq laotie");

        listenStrategy.doWork(" AMD YES!!!");
    }
}
